using System;
using Entities;
using DAL;
using System.Configuration;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;

namespace BUS
{
    public class tbHinhAnhBUS
    {
        public static void Insert(tbHinhAnhEntities hinhanh)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            hinhanhDAL.Insert(hinhanh);
        }
        public static void Update(tbHinhAnhEntities hinhanh)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            hinhanhDAL.Update(hinhanh);
        }
        public static void Delete(int iD)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            hinhanhDAL.Delete(iD);
        }
        public static tbHinhAnhEntities.tbHinhAnhEntitiesCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            return hinhanhDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbHinhAnhEntities.tbHinhAnhEntitiesCollection GetAll()
        {
            int total = 0;
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            return hinhanhDAL.Get("where 1=1", 0, 0, tbHinhAnhEntities.tbHinhAnhEntitiesColumns.MaSP.ToString(), "ASC", out total);
        }
        public static tbHinhAnhEntities GetByID(int iD)
        {
            int total = 0;
            tbHinhAnhDAL hinhanhDAL = new tbHinhAnhDAL();
            tbHinhAnhEntities.tbHinhAnhEntitiesCollection hinhanhCollection = hinhanhDAL.Get("where " + tbHinhAnhEntities.tbHinhAnhEntitiesColumns.STT.ToString() + "=" + iD.ToString(), 0, 0, tbHinhAnhEntities.tbHinhAnhEntitiesColumns.STT.ToString(), "ASC", out total);
            if (hinhanhCollection.Count > 0)
                return hinhanhCollection[0];
            return null;
        }
        public static int imageFirst(int IdSanPham)
        {
            tbHinhAnhDAL hinhAnh = new tbHinhAnhDAL();
            return hinhAnh.imageFirst(IdSanPham);
        }
    }
}
